#include<bits/stdc++.h>
using namespace std;
int n,m,L,V;
struct node
{
    double d,v0,a0;
};
vector<int>a[100001];
double zb[100001];
int tot,ans2;
node car[100001];
bool h[200001],hx[200001];
void dfs(int dep,int sum)
{
    bool tot=1;
    for(int i=1;i<=n;i++)
    {
        if(hx[i]==0&&h[i]==1)tot=0;
    }
    if(tot==1)
    {
        ans2=min(ans2,sum);
        return ;
    }
    if(dep>m)return;
    for(int i=0;i<a[dep].size();i++)
    {
        int v=a[dep][i];
        hx[v]=1;
    }
    dfs(dep+1,sum+1);
    for(int i=0;i<a[dep].size();i++)
    {
        int v=a[dep][i];
        hx[v]=0;
    }
    dfs(dep+1,sum);
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int T,ans1;
    cin>>T;
    while(T--)
    {
        ans1=0,ans2=0;
        memset(h,0,sizeof(h));
        for(int i=1;i<=100001;i++)a[i].clear();
        cin>>n>>m>>L>>V;
        for(int i=1;i<=n;i++)
        {
            cin>>car[i].d>>car[i].v0>>car[i].a0;
        }
        for(int i=1;i<=m;i++)cin>>zb[i];
        for(int i=1;i<=m;i++)
        {
            for(int j=1;j<=n;j++)
            {
                double now=zb[i];
                if(car[j].d>now)continue ;
                double s=now-car[j].d;
                double v=sqrt(car[j].v0*car[j].v0+2*car[j].a0*s);
                if(v>V)
                {
                    a[i].push_back(j);
                    if(h[j]==0)
                    {
                        ans1++;
                    }
                    h[j]=1;
                }
            }
        }
            ans2=INT_MAX;
            memset(hx,0,sizeof(hx));
            dfs(1,0);
        cout<<ans1<<" "<<m-ans2<<"\n";
    }
}
/*
1
5 5 15 3
0 3 0
12 4 0
1 1 4
5 5 ‐2
6 4 ‐4
2 5 8 9 15
*/













